package com.itheima.book.manager.factory;

import com.itheima.book.manager.dao.BaseBookDao;
import com.itheima.book.manager.dao.BookFileDao;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class BookDaoFactory {

    public static BaseBookDao getBookDao(){

        try {
            Properties properties = new Properties();
            properties.load(new FileInputStream("itheima-book-manager\\config/book-dao-info.properties"));
            String propertiesValue = properties.getProperty("book-dao-info");
            Class<?> baseBookDaoClass = Class.forName(propertiesValue);
            BaseBookDao baseBookDao = (BaseBookDao) baseBookDaoClass.newInstance();
            return baseBookDao;
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }
}
